package com.sduept.nwld.dataserver.manager.statistics;

import com.sduept.core.dao.SuperDAO;
import com.sduept.nwld.dataserver.model.countanalyse.TansmissionLineInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 输电线路长度查询manager
 * @author huangyu
 * @Date 2019年7月17日
 */

@Service
public class TransmissionLineManager {

	@Autowired
	private SuperDAO dao;
	
	public List<TansmissionLineInfo> getAllTansmissionLineInfo() {
		return dao.findAll(TansmissionLineInfo.class);
	}
	
	public TansmissionLineInfo createOrUpdateTansmissionLineInfo(TansmissionLineInfo tl) {
		return dao.createOrUpdate(tl, TansmissionLineInfo.class);
	}
	
	public void deleteTansmissionLineInfo(String id) {
		dao.delete(id, TansmissionLineInfo.class);
	}
	
	public List<TansmissionLineInfo> getTansmissionLineInfos(Integer year, Integer voltage) {
		String esql = " 1=1 ";
		List<Object> param = new ArrayList<Object>();
		if(null != year) {
			esql += " and year = ?";
			param.add(year);
		}
		if(null != voltage) {
			esql += " and voltage = ?";
			param.add(voltage);
		}
		return dao.findByCondition(TansmissionLineInfo.class, esql, param.toArray());
	}
	
}
